
function login() {
    // 获取username  password
    const username = $('.input_txt').val();
    const password = $('.input_pass').val();
    if (username && password) {
        // ajax请求：
        $.ajax({
            type: "post",
            url: "http://localhost:8080/api/v1/admin/user/login",
            data: { username, password },
            // dataType: "dataType",
            success: function (response) {
                // 把token存到本地：
                console.log(response);
                if (response.code === 200) {
                    console.log(response);
                    window.localStorage.setItem("token", response.token);
                    window.location.href = "./index.html";
                } else if (response.code === 400) {
                    // alert(response.msg);
                    $('#loginModal').modal('show');
                    $('.modal-body').html(response.msg)
                }

            }
        });
    } else {
        // alert('请输入正确的账号和密码~~');
        // 设置模态框文本内容
        $('#loginModal').modal('show');
        $('.modal-body').html('账号和密码不能为空啊~~')
    }
}
